home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Swirl is a program that repeatedly modifies images in a regular way,
- and often generates interesting patterns.
-
- Try it out with the following calling sequences:
-
- swirl 1 8 8
- swirl 0 3 3
- swirl 7 8 8
- swirl 1 1 5
- swirl 5 1 3 0.5 2
-
- Be patient -- it takes a little while to start up; once it starts
- cycling, it works pretty well.
-
- The user interface is about as hostile as can be. Here it is:
-
- type 'q' to quit.
- type 's' to stop cycling
- type 's' to start cycling again
- type 'i' to save the window as the image file "out.rgb"
- (the window title bar reminds you of the parameters you
- used, and displays the current generation number.)
-
- Note: When you type 's' to stop it, swirl will continue to calculate
- the next generation until it is done, and will then display it. Thus,
- the "stop" command will not have an instant effect. Just to prove that
- the interface is as hostile as possible, I've rigged it so that if you
- type another 's' because you think the first one didn't "take", that
- will re-start it.
-
- Swirl takes 3, 4, or 5 parameters. The first three must be integers.
-
- Parameter 1 defines the initial pattern. It can be any number from -1
- to 7. Patterns 1-7 are built-in patterns, and pattern 0 is solid black,
- except that a middle square of pixels is turned on each generation. If
- you specify -1 for a pattern, swirl will read the image file called
- "in.rgb" in your current directory, and will use it as the initial
- pattern. There is no limit on the image size, but big images run pretty
- slowly.
-
- Parameters 2 and 3 specify the dx and dy transformations to use on each
- generation. Currently, values between 1 and 20 are valid. See below
- for a description of what dx and dy mean. The value 0 for dx or dy
- means no operation so you can get pure x or y distortion. "swirl n 0 0"
- does nothing forever.
-
- Parameters 4 and 5 are two floating-point parameters that are used to
- modify many of the dx and dy transformations. Their results vary from
- transformation to transformation, and by default, their values are
- 1.0. It is often a good idea to use small integers for parameters 4
- and 5.
-
- What it does:
-
- I was trying to find some simple algorithms that generate interesting
- patterns that could possibly be used as textures for texture maps, etc.
- All of the patterns produced wrap from top to bottom, and left to right.
-
- Swirl works as follows: For each pixel (i, j) I keep 5 values -- the R,
- G, and B components, and two floats, dx(i, j) and dy(i, j). Typically,
- the floats are small (on the order of -15 to 15). Generation n+1 is
- calculated from generation n as follows:
-
- At the pixel (i, j), find dx = dx(i, j) and dy = dy(i, j).
-
- Find the color (in generation n) of pixel (i+dx, j+dy). Since
- dx and dy are, in general, floats, do the appropriate filtering.
- (If you go off the image, just wrap to the opposite side.)
-
- Assign this new color to the pixel (i, j) in generation n+1.
-
- Basically, the dx and dy values form a 2-D vector field that indicate
- the flow direction (actually the negative of that). If the dx and dy
- are sinusoidal, you'll get swirling. You can also do shearing,
- electric attractive and repulsive fields, etc.
-
-
- Suggestions welcome; bugs to /dev/null. The code may change, but I'll
- add features using higher numbers for starting values and dx and dy
- specifications.
- -- Tom Davis (davis@sgi.com)
-